package org.huamoxi.utils;

/**
 * 请求来源识别工具类
 */
public class DiscernRequestUtils {
    /**
     * 识别请求是 手机端（分系统） 还是电脑端
     * @return
     */
    public static String getRequestDevice(String userAgent) {
        userAgent=userAgent.toLowerCase();
        if (userAgent.contains("windows phone")){
            return  "Windows手机端";
        }else if (userAgent.contains("android")) {
            return  "安卓手机端";
        }else if(userAgent.contains("iphone") || userAgent.contains("ipad")){
            return  "ios手机端";
        }else {
            return  "电脑端";
        }
    }

    /**
     * 识别请求是手机端还是电脑端
     * @return
     */
    public static String getAskType(String userAgent) {
        userAgent=userAgent.toLowerCase();
        if (userAgent.contains("windows phone")
                ||
                userAgent.contains("android")
                ||
                userAgent.contains("iphone")
                ||
                userAgent.contains("ipad") //暂且把ipad也归为苹果设备
        ){
            return  "mobile";
        }else {
            return  "pc";
        }
    }
}
